import { ElMessage } from 'element-plus';
export const errorHandling = async (fn, args, finallyCallback, errorCallBack) => {
    try {
        const res = await fn(args);
        if (res.code === 0) {
            finallyCallback && finallyCallback(res);
            return res;
        }
        else {
            // code错误时的回调
            if (errorCallBack) {
                errorCallBack(res);
            }
            else {
                ElMessage.error(res.msg || '报错了');
            }
        }
    }
    catch (err) {
        errorCallBack && errorCallBack(err);
    }
};
